package com.module.controller;

import com.module.framework.domain.Indemnify;
import com.module.framework.domain.ResponseResult;
import com.module.framework.dto.IndemnifyDTO;
import com.module.framework.dto.IndemnifyListDTO;
import com.module.framework.service.IndemnifyService;
import com.module.framework.vo.PageVO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/admin/indemnify")
public class IndemnifyController {

    @Resource
    private IndemnifyService indemnifyService;

    @PostMapping("/add")
    public ResponseResult add(@RequestBody IndemnifyDTO indemnifyDTO) {
        indemnifyService.add(indemnifyDTO);
        return ResponseResult.okResult();
    }

    @PostMapping("/list")
    public ResponseResult list(@RequestBody IndemnifyListDTO indemnifyListDTO) {
        System.out.println(indemnifyListDTO);

        PageVO pageVO = indemnifyService.getPage(indemnifyListDTO);
        return ResponseResult.okResult(pageVO);
    }

    @PostMapping("/change")
    public ResponseResult change(Integer id) {
        System.out.println(id);
        Indemnify indemnify = indemnifyService.getById(id);
        indemnify.setCompensationStatus("2");
        indemnifyService.updateById(indemnify);
        return ResponseResult.okResult();
    }
}
